cmake_minimum_required(VERSION 3.16)
project(gamepad_event)

# 查找核心依赖
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)


file(GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gamepad_reader/*.cpp)

# 动态获取 libevdev 路径
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBEVDEV REQUIRED libevdev)

# 添加可执行文件
add_executable(gamepad_node src/gamepad_reader.cpp)

# 设置头文件路径
target_include_directories(gamepad_node PRIVATE
  ${LIBEVDEV_INCLUDE_DIRS}
)

target_link_libraries(gamepad_node evdev)

# 链接 ROS 2 库
ament_target_dependencies(gamepad_node rclcpp geometry_msgs)

# 安装配置
install(TARGETS gamepad_node DESTINATION lib/${PROJECT_NAME})

# 声明依赖导出（关键）
ament_export_dependencies(
  rclcpp
  geometry_msgs
)

ament_package()